Matrix Rectification

EllipsePiOver3.png
Figure 1: The ellipse equation is $-\frac{5}{18}\sqrt{3}(x-7)(y-4)+\frac{31}{36}(x-7)^{2}+\frac{7}{12}(y-4)^{2}=4$. The center is $(7,4)$ and it has been rotated to an angle of $\pi/3$.

Our general form conic equation is $$Ax^{2}+Bxy+Cy^{2}+Dx+Ey+F=0 \tag{1} \label{1}$$ Suppose we begin with this ellipse equation: $$\begin{aligned} & -\frac{5}{18}\sqrt{3}(x-7)(y-4)\\ & +\frac{31}{36}(x-7)^{2}\\ & +\frac{7}{12}(y-4)^{2}=4.\\ \end{aligned} $$ so that the coefficients of the terms are easily identified, and just for the convenience of observation, we will print it with approximate values. $$\begin{aligned} &0.861x^{2} -0.481xy+0.583y^{2}\\ &-10.131x-1.299y=-34.056\\ \end{aligned}$$ We have been given the center of this ellipse, but in a more general case, we would need to find it. That is conveniently done by setting the gradient to zero and solving for $x$ and $y$ simultaneously. $$\nabla f=\left(\begin{array}{c} \partial f/\partial x\\ \partial f/\partial y \end{array}\right)=\left(\begin{array}{c} 1.722x-.481y-10.131\\ 1.166y-.481x-1.299 \end{array}\right)=0\qquad\left(\begin{array}{c} x\\ y \end{array}\right)=\left(\begin{array}{c} 7\\ 4 \end{array}\right)$$ This center point cannot be found for a parabola, but with an "axis aligned" parabola, we can set $\partial f/\partial x=0$ for the squared term and solve for $x$. Then in the parabola equation plug in the found $x$ and solve for $y$. That $(x,y)$ pair will be the vertex of the parabola.

Using the centerpoint, we can translate the ellipse to the origin. To do the translation, for $x$ substitute $(x+7)$ and for $y$ substitute $(y+4)$. The equation will then reduce to $$-\frac{5}{18}\sqrt{3}xy+\frac{31}{36}x^{2}+\frac{7}{12}y^{2}=4.$$ Now we are going to take the coefficients $A$, $B$, and $C$ from $\eqref{1}$ and put them into a matrix, $Q$, as follows: $$Q=\left(\begin{array}{cc} A & \frac{B}{2}\\ \frac{B}{2} & C \end{array}\right)=\left(\begin{array}{cc} \frac{31}{36} & \frac{-5\cdot\sqrt{3}}{(18\cdot2)}\\ \frac{-5\cdot\sqrt{3}}{(18\cdot2)} & \frac{7}{12} \end{array}\right)$$ Next we will find the eigenvalues of $Q$ using the characteristic matrix. $$\left(\begin{array}{cc} \frac{31}{36}-\lambda & \frac{-5\cdot\sqrt{3}}{(18\cdot2)}\\ \frac{-5\cdot\sqrt{3}}{(18\cdot2)} & \frac{7}{12}-\lambda \end{array}\right)=0$$ $$\left(\begin{array}{c} \lambda_{1}\\ \lambda_{2} \end{array}\right)=\left(\begin{array}{c} 1\\ \frac{4}{9} \end{array}\right)$$

EllipsePiOver3_1.png
Figure 2: The original ellipse has center $(7,4)$. It has been translated to the origin by replacing $x$ in the orginal equation with $(x+7)$ and replacing $y$ with $y+4$. The new equation is $$\begin{aligned} &\frac{31}{18}\;\left(x+7\right)^{2} +\frac{7}{6}\;\left(y+4\right)^{2}\\ &-\frac{3512600}{3650401}\;\left(x+7\right)\;\left(y+4\right)\\ &-\frac{19216625}{948402}\;\left(x+7\right) -\frac{1407743}{541944}\;\left(y+4\right)\\ &=-\frac{4614148}{67743}\end{aligned}.$$ Which is approximately $1.72x^{2}-0.96xy+1.17y^{2}=8.$
and the eigenvectors of $Q$. Note: These are not unique and we will want them as unitvectors and we need to match them with the eigenvalues. In this case, $\mathbf{u}$ goes with $\lambda_{1}$. $$\mathbf{u}=\left(\begin{array}{c} 3\\ -\sqrt{3} \end{array}\right)\qquad\mathbf{v}=\left(\begin{array}{c} 1\\ \sqrt{3} \end{array}\right)$$ $$\mathbf{u}=\frac{\left(\begin{array}{c} 3\\ -\sqrt{3} \end{array}\right)}{\left\Vert \left(\begin{array}{c} 3\\ -\sqrt{3} \end{array}\right)\right\Vert }\qquad\mathbf{v}=\frac{\left(\begin{array}{c} 1\\ \sqrt{3} \end{array}\right)}{\left\Vert \left(\begin{array}{c} 1\\ \sqrt{3} \end{array}\right)\right\Vert }$$ Having translated the matrix to the origin and obtained eigenvectors, we have figure 2.

What we have done so far will go a long way toward getting desired parameters. For example, since we have direction vectors $(\mathbf{u,}\mathbf{v})$ for the principle axes, we can write an equation to put lines through the ellipse. Below is the principle axis line. If we intersect it with the ellipse, we will get the vertices, which can be used to get other parameters. This equation is the major axis of the original ellipse. $$\left(\begin{array}{c} x\\ y \end{array}\right)=Center+t\mathbf{v}=\left(\begin{array}{c} 7\\ 4 \end{array}\right)+t\cdot\left(\begin{array}{c} v_{x}\\ v_{y} \end{array}\right)$$ We can also take the translated ellipse and rotate it to align with the axis. Either vector will yield an alignment angle $\theta$ using $$\left(\begin{array}{c} \theta_{1}\\ \theta_{2} \end{array}\right)=\left(\begin{array}{c} \arg(\mathbf{v})\\ \arg(\mathbf{u}) \end{array}\right)=\left(\begin{array}{c} 60^{\circ}\\ -30^{\circ} \end{array}\right).$$
EllipsePiOver3_2.png
Figure 3: We started with the non-centered, rotated equation, $c$, and translated it to the origin. Then we use $\arg(\mathbf{v})$ to learn that a $60^{\circ}=\pi/3$ rotation would get alignment. That is the ellipse $g$. Its equation is $0.89x^{2}+2y^{2}=8$.
Once we have an aligned equation at the origin, we can let either $x=0$ or $y=0$ and solve for the other variable to obtain parameters $a$ and $b$. In this case, $a=3$ and $b=2$ and the oriented, centered ellipse can be written as $$\frac{x^{2}}{3^{2}}+\frac{y^{2}}{2^{2}}=1.$$ Also, with $a$, we can use vector $\mathbf{v}$ to project the vertices of the original. Let $Cen$ be the center point of the original ellipse, then $$V_{1}=Cen+a\cdot\mathbf{u}.$$

Matrix alignment

Reference: Matrix representation of conic sections, Wikipedia, Wikimedia Foundation, October 2019, https://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections

An aligned and origin centered ellipse can be accomplished as follows. Form matrix $Q$ as before. $$Q=\left(\begin{array}{cc} A & B/2\\ B/2 & C \end{array}\right)$$ Form a new matrix called A_{q}. $$A_{q}=\left(\begin{array}{ccc} A & B/2 & D/2\\ B/2 & C & E/2\\ D/2 & E/2 & F \end{array}\right)$$ Using $Q$, find the eigenvalues, $\lambda_{1}$ and $\lambda_{2}$. Now the aligned and origin centered ellipse will be $$\lambda_{1}x^{2}+\lambda_{2}y^{2}=\frac{-determinant(A_{q})}{determinant(Q)}$$